import request from "../../utils/request";
import {message} from 'antd';
import type {AxiosResponse} from 'axios'
export const handleDrugsList = async (params: any): Promise<AxiosResponse> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/drugs/list', params)
        return res.data
    } catch (err) {
        message.error('获取医疗药品列表失败')
        throw err
    }
}
export const handleDrugsDel = async (params: any): Promise<AxiosResponse> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/drugs/del', params)
        return res.data
    } catch (err) {
        message.error('医疗药品列表删除失败')
        throw err
    }
}
export const handleUpLoad = async (data: any): Promise<AxiosResponse> => {
    try {
        const res: AxiosResponse<any, any> = await request.post('/drugs/uploaddrugs', data)
        return res.data
    } catch (err) {
        message.error('医疗药品列表删除失败')
        throw err
    }
}
export const handleAddDrugs = async (data: any): Promise<AxiosResponse> => {
    try {
        const res: AxiosResponse<any, any> = await request.post('/drugs/add', data)
        return res.data
    } catch (err) {
        message.error('添加药品失败')
        throw err
    }
}
export const handleBatchDrugs = async (data: any): Promise<AxiosResponse> => {
    try {
        const res: AxiosResponse<any, any> = await request.post('/drugs/batchdel', data)
        return res.data
    } catch (err) {
        message.error('批量删除失败')
        throw err
    }
}
export const handleEditDrugs = async (params: any): Promise<AxiosResponse> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/drugs/edit', params)
        return res.data
    } catch (err) {
        message.error('修改药品失败')
        throw err
    }
}
export const handleSearchDrugs = async (params: any): Promise<AxiosResponse> => {
    try {
        const res: AxiosResponse<any, any> = await request.get('/drugs/search', params)
        return res.data
    } catch (err) {
        message.error('查询药品失败')
        throw err
    }
}